package demo2;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * User: 12629
 * Date: 2021/10/30
 * Time: 17:05
 * Description:
 */
class Person implements Cloneable{
    @Override
    protected Object clone() throws CloneNotSupportedException {
        return super.clone();
    }
}
public class TestDemo {

    public static void function() {
        int[] array = {1,2,3,4,5};
        System.out.println(array[100]);
    }

    public static void main(String[] args) {
        try {
            function();
        }catch (ArrayIndexOutOfBoundsException e) {
            System.out.println("数组越界异常");
            e.printStackTrace();
        }
        System.out.println("dfafsafdsaf");
    }

    public static int func2() {
        try {
            int a = 10;
            return a;//10
        }catch (NullPointerException e) {

        }finally {
            return 99;
        }
    }

    public static void main13(String[] args) {
        int a = func2();
        System.out.println(a);
    }


    public static void main12(String[] args) {
        int[] array = {1,2,3,4};
        try {
            System.out.println(array.length);
            System.out.println("gaobo");
        }catch (NullPointerException e) {
            System.out.println("NullPointerException");
            e.printStackTrace();
        }catch (ArrayIndexOutOfBoundsException e){
            System.out.println("ArrayIndexOutOfBoundsException");
            e.printStackTrace();
        }finally {
            //关闭文件等数据
            System.out.println("finally 执行了");
        }
    }
    public static void main11(String[] args) {
        int[] array = null;
        try (Scanner scanner = new Scanner(System.in)) {
            System.out.println(array.length);
            System.out.println("gaobo");
        } catch (NullPointerException e) {
            System.out.println("NullPointerException");
            e.printStackTrace();
        } catch (ArrayIndexOutOfBoundsException e) {
            System.out.println("ArrayIndexOutOfBoundsException");
            e.printStackTrace();
        }
        //关闭文件等数据

        System.out.println("fdsfsaafa");

    }
    /*public static void main(String[] args) {
        int[] array = null;

        try {
            System.out.println(array.length);
            System.out.println("gaobo");
        }catch (Exception e) {
            System.out.println("这个是一个异常");
            e.printStackTrace();

        }catch (ArrayIndexOutOfBoundsException e){
            System.out.println("这个是一个数组越界异常");
            e.printStackTrace();
        }

        System.out.println("fdsfsaafa");

    }*/

    public static void main4(String[] args) {
        int[] array = null;

        try {
            System.out.println(array.length);
            System.out.println("gaobo");
        }catch (NullPointerException e) {
            System.out.println("这个是一个空指针异常");
            e.printStackTrace();

        }catch (ArrayIndexOutOfBoundsException e){
            System.out.println("这个是一个数组越界异常");
            e.printStackTrace();
        }

        System.out.println("fdsfsaafa");

    }
    public static void main3(String[] args) {
        int[] array = null;
        try {
            System.out.println(array.length);
            System.out.println("gaobo");
        }catch (NullPointerException | ArrayIndexOutOfBoundsException e) {
            System.out.println("这个是一个空指针或者数组越界异常");
            e.printStackTrace();
        }
        System.out.println("fdsfsaafa");

    }

    public static void main2(String[] args) throws CloneNotSupportedException {
        Person person = new Person();
        Person person2 = (Person) person.clone();
    }

    public static void func() {
        func();
    }

    public static void main1(String[] args) {
        func();
        /*int[] array = null;
        System.out.println(array.length);
        System.out.println("gaobo henshuai");*/
    }

}
